import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {Properties} from 'ngx-pinch-zoom';
import {ToastService} from '../../common/service/toast.service';
import {PopoverController} from '@ionic/angular';
import {PopoverComponent} from './popover/popover.component';


@Component({
    selector: 'app-product-show',
    templateUrl: './product-show.page.html',
    // styleUrls: ['./product-show.page.less'],
})
export class ProductShowPage implements OnInit {
    fullScreen = false; // 全屏显示产品图片
    fullScreenImg = ''; // 全屏显示产品图片的url
    showMoreSign = false; // 展示更多标记
    currentPopover = null;
    slideOpts = {
        initialSlide: 0,
        speed: 400,
        // loop: true
    };
    // 普通图片最大放大倍数设置为100倍
    properties: Properties = {
        'limit-zoom': 100,
        // wheelZoomFactor: 2,
        // zoomControlScale: 100,
        // overflow: 'visible',
        // disableZoomControl: 'disable'
    };

    product = {
        // 产品信息
        productParameter: {
            id: '202008111345',
            code: '001',
            name: '浪潮天梭K1 950',
            model: 'K1 950',
            serialNumber: 'TG-2016',
            price: '9999999',
            remarks: '全新架构 性能强劲',
            productManufacturer: '浪潮集团',
            productUuid: 'AAABBBCCC',
            assetUser: '中铁宝桥',
            img: [
                {src: '\\assets\\img\\0.jpg'},
                {src: '\\assets\\img\\1.jpg'},
                {src: '\\assets\\img\\2.jpg'},
                {src: '\\assets\\img\\3.jpg'}
            ],
            details: '全新架构 性能强劲\n' +
                '\n' +
                '　　浪潮天梭K1 950采用双翼扩展紧耦合体系结构，实现多平面互连冗余及互连网络单跳步32路扩展，有效降低互连延迟，增强系统可靠性和扩展性，为系统高可用能力奠定架构基础。\n' +
                '\n' +
                '　　该架构为系统的高可用能力奠定了基础，同时也是我国首个获得国际PCT专利授权的关键应用主机体系结构设计发明专利（专利号：PCT/CN2008/001834）。浪潮天梭K1 950的问世，使中国成为世界上第三个能够独立自主研发小型机的国家。\n' +
                '\n' +
                '　　浪潮天梭K1 950最高可拥有256个计算核心，轻松应对关键应用对性能的要求；4096GB内存扩展可方便地支持对内存有苛刻要求的应用。',
            electronicSample: '202010290001'
        },
        // 主机信息
        hostParameter: {
            id: '202008111348',
            code: '01',
            name: '浪潮天梭K1 950',
            model: 'K1 950',
            markingRange: '175*175',
            laserType: 'K1',
            power: '30W',
            accessories: '无',
            img: [
                {src: 'https://www.inspur.com/lcjtww/2315499/2315503/2316283/2318425/2318445/2424307/2018092911043241605.png'},
                {src: 'https://www.inspur.com/lcjtww/2315499/2315503/2316283/2318425/2318445/2424307/2018092911043418250.png'},
                {src: 'https://www.inspur.com/lcjtww/2315499/2315503/2316283/2318425/2318445/2424307/2018092911042788458.png'}
            ],
            details: '浪潮天梭K1 950，采用模块化架构和全冗余技术，充分保障业务系统随需而动，弹性部署，以更优方式提供高性能、高可用、高效率的IT资源',
            electronicSample: '无'
        },
        // 制造商
        manufacturer: {
            id: '0001',
            code: '202008111403',
            name: '浪潮集团通用软件有限公司',
            address: '山东省济南市高新浪潮路1036号',
            tel: '0531-85106000',
            branchOffice: [{
                id: '000101',
                code: '202008111405',
                name: '浪潮电子信息产业股份有限公司',
                address: '山东省济南市高新浪潮路1036号',
                tel: '400-600-2345',
                img: {src: 'assets/application/scan/产品图.png'}
            }, {
                id: '000102',
                code: '202008111406',
                name: '浪潮软件股份有限公司',
                address: '山东省济南市高新浪潮路1036号',
                tel: '400-600-2345',
                img: {src: 'assets/application/scan/产品图.png'}
            }, {
                id: '000103',
                code: '202008111407',
                name: '浪潮国际有限公司',
                address: '山东省济南市高新浪潮路1036号',
                tel: '400-600-2345',
                img: {src: 'assets/application/scan/产品图.png'}
            }],
            img:
                {src: 'https://bkimg.cdn.bcebos.com/pic/09fa513d269759eeee6f0d60bafb43166d22df5a?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2U5Mg==,g_7,xp_5,yp_5'}

        }
    };
    // 页面中间的网格菜单数据
    gridMenuData = [
        {code: '3', name: '产品秀', img: '产品秀.svg', href: '/tabs/application/threeDimensional', title: '原厂配件 质量保证'},
        {code: 'repair', name: '故障报修', img: '故障报修.svg', href: '/tabs/application/malfunctionRepair', title: '一键报修 专人负责'},
        {code: '6', name: '动态鉴伪', img: '动态鉴伪.svg', href: '/tabs/application/dynamicCertification', title: '快捷分辨 产品真伪'},
        {code: '5', name: '质量追溯', img: '质量追溯.svg', href: '/tabs/application/qualityTraceability', title: '一机一册 方便省心'},
    ];


    constructor(
        private router: Router,
        private toast: ToastService,
        private popover: PopoverController
    ) {
    }

    ngOnInit() {
    }

    ionViewWillLeave() {
        // 关闭popover页面
        if (this.currentPopover) {
            this.currentPopover.dismiss().then(() => {
                this.currentPopover = null;
            });
        }
    }

    async openPopover(ev: any) {
        const popover = await this.popover.create({
            component: PopoverComponent,
            cssClass: 'my-custom-class',
            event: ev,
            translucent: true
        });
        this.currentPopover = popover;
        return await popover.present();
    }

    // 跳转到 3D 展示页面
    go3D() {
        this.router.navigate(['/tabs/application/threeDimensional']);
        // this.router.navigate(['/tabs/tab1/productShowcase/productMenu'], {
        //   queryParams: {
        //     code: '2',
        //     name: '3D秀',
        //     href: '/tabs/tab1/productShowcase/productMenu'
        //   }
        // });
    }

    goInquirePrice(productParameter: any) {

    }

    showToast() {

    }

    goProductDetails(productDetails: string, productParameter: any) {

    }

    goproductMenu(关于企业: string) {

    }

    // 查看详情
    goDetails() {
        this.router.navigate(['/tabs/application/productArchive']);
    }

    // 路由跳转
    routerJump(href: string | SVGAnimatedString, item: any) {
        if (href) {
            this.router.navigate([href]);
        } else {
            this.toast.warnToast('该功能暂未开放!');
        }

    }

    getBaiduMapGeolocation() {
        this.toast.warnToast('该功能暂未开放!');
    }

    loadMore() {
        this.toast.warnToast('该功能暂未开放!');
    }


}
